package com.junzhiit.nengji.model.enums;

import com.bainaeco.framework.exception.InvalidArgumentException;

public enum OrderType {
	
	SHOP(0,"到店"),
	DELIVERY(1,"配送"),
	MAIL(2,"直邮"),
	EAT(3,"堂食"),
	RESERVE(4,"预定"),
	EXTRACT(5,"自提");
	
	private Integer value;
	private String text;

	private OrderType(Integer value,String text) {
		this.value = value;
		this.text = text;
	}

	public int toIntValue() {
		return this.value;
	}
	
	public String toStringText() {
		return this.text;
	}

	public static OrderType toType(Integer value) {
		if (SHOP.value == value) {
			return SHOP;
		} else if (DELIVERY.value == value) {
			return DELIVERY;
		} else if (MAIL.value == value) {
			return MAIL;
		} else if (EXTRACT.value == value) {
			return EXTRACT;
		} else if (RESERVE.value == value) {
			return RESERVE;
		} else if (EAT.value == value) {
			return EAT;
		} else {
			throw new InvalidArgumentException("Unknown OrderType[" + value + "].");
		}
	}
}
